<script setup lang="ts">
import { formatEnum, get, loadFile, message, post } from '@/utils'
import useModal from '@/hooks/useModal'
import HelpModal from './components/HelpModal.vue'
import useTable from '@/hooks/useTable'
enum Status {
  '授权' = 0,
  '提交' = 1,
  '新增' = 2,
  '修改' = 3,
  '删除' = 4,
  '审核' = 5,
}
const { formatColumns } = useTable()
const searchQuery = reactive({})
const formRef = ref()
const actionRef = ref()

const pagination = {
  showPageSize: true,
  pageSize: 20,
}
const request = (params: any, sort: any, filters: any): Promise<any> => {
  return new Promise((resolve, reject) => {
    const query = { ...params, size: params.pageSize }
    Reflect.deleteProperty(query, 'pageSize')
    get(
      {
        url: '/server-system/admin/operate/log/page',
        data: query,
      },
      ({ data, code }) => {
        resolve({
          data: data.records,
          total: data.total,
          success: code == 200,
        })
      }
    )
  })
}
const columns = formatColumns([
  { title: '操作人', dataIndex: 'operateName', width: 200, hideInSearch: false },
  { title: '操作人ID', dataIndex: 'operateId', width: 200, hideInSearch: false },
  { title: '操作类型', dataIndex: 'operateType', valueEnum: formatEnum(Status), width: 200, hideInSearch: false },
  { title: '操作IP', dataIndex: 'requestIp', width: 200 },
  { title: '操作描述', dataIndex: 'remark', width: 200, hideInSearch: false },
  { title: '请求参数', dataIndex: 'requestParam', width: 400, ellipsis: true, hideInSearch: false },
  // { title: '请求地址', dataIndex: 'requestUrl' },
  // { title: '响应参数', dataIndex: 'responseParam' },
  { title: '操作时间', dataIndex: 'createTime', width: 200 },
])
</script>

<template>
  <div class="page">
    <ProTable :columns="columns" :request="request" row-key="id" :form-ref="ref => (formRef = ref)" :pagination="pagination" header-title="" :scroll="{ x: 1000 }" column-resizable :params="searchQuery" :bordered="{ cell: true }" :action-ref="ref => (actionRef = ref)">
      <template #option-render="{ dom, reset }">
        <component :is="dom[1]" />
        <component :is="dom[0]" />
        <!-- <a-button @click="store.handleShow({})" type="primary">
          <template #icon>
            <icon-plus />
          </template>
          新建</a-button
        > -->
      </template>
    </ProTable>
  </div>
</template>
